package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.WechatMenu;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class WechatMenuDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "菜单名称")
    private String name;

    @ApiModelProperty(value = "菜单类型")
    private String type;

    @ApiModelProperty(value = "菜单key值")
    private String buttonKey;

    @ApiModelProperty(value = "地址")
    private String url;

    @ApiModelProperty(value = "父级id")
    private Integer fatherId;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty("子级数据")
    private List<WechatMenu> sub_button;


    public WechatMenuDTO() {}

    public WechatMenuDTO(WechatMenu entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static WechatMenuDTO convert(WechatMenu entity) {
        return new WechatMenuDTO(entity);
    }

    public static List<WechatMenuDTO> convertList(List<WechatMenu> list) {
        List<WechatMenuDTO> resultList = new ArrayList<>();
        for (WechatMenu entity : list) {
            resultList.add(new WechatMenuDTO(entity));
        }
        return resultList;
    }}
